package com.forg.mvc.core.common.groovy;

import java.util.Map;

import groovy.lang.Script;

public class GroovyClass {
    
    public GroovyClass(){
        
    }
    
    public GroovyClass(Script script,long lastmodified){
        this.script = script;
        this.lastmodified = lastmodified;
    }
    
    Script script;
    
    long lastmodified = 0;

    
    public Script getScript() {
        return script;
    }

    public void setScript(Script script) {
        this.script = script;
    }

    public long getLastmodified() {
        return lastmodified;
    }

    public void setLastmodified(long lastmodified) {
        this.lastmodified = lastmodified;
    }

    public Object invoke(String methosName, Object[] args) {
        return script.invokeMethod(methosName, args);
    }

    public Object get() {
        return script.run();
    }

    public Object get(Map binds) {
        script.getBinding().getVariables().putAll(binds);
        Object obj = script.run();
        return obj;
    }    
    

}
